package com.eamois.ui.util;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.net.URL;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
import javax.swing.border.EtchedBorder;

public class PnlImageBottom extends JPanel {
	private static final long serialVersionUID = 1L;
	private Image image = null;

	/**
	 * This is the default constructor
	 */
	public PnlImageBottom() {
		super();
		initialize();

		URL url = com.eamois.icon.GetIcons.class.getResource("imageBottom.jpg");
		this.setImage(Toolkit.getDefaultToolkit().getImage(url));
		MediaTracker tracker = new MediaTracker(this);
		tracker.addImage(this.getImage(), 0);
		try {
			tracker.waitForID(0);
		} catch (Exception ex) {
		}
	}

	public void paintComponent(Graphics g) {
		try {
			super.paintComponents(g);
			int width = this.getParent().getSize().width;
			g.drawImage(this.getImage(), 0, 0, width, 200, this);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		// int width = this.getParent().getSize().width;
		this.setSize(400, 200);
		this.setLayout(new GridBagLayout());
		this.setPreferredSize(new Dimension(400, 200));
		this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
	}

	public void setImage(Image image) {
		this.image = image;
	}

	public Image getImage() {
		return image;
	}
}
